import Vue from 'vue'

// 初始化样式
import 'normalize.css/normalize.css' // A modern alternative to CSS resets

// 用了element组件库
import ElementUI from 'element-ui'
// element样式
import 'element-ui/lib/theme-chalk/index.css'

// 语言切换 国际化 lang language 语言 引用的en 指的就是英文
// import locale from 'element-ui/lib/locale/lang/en' // lang i18n

// 全局样式
import '@/styles/index.scss' // global css

// 根组件
import App from './App'
// 仓库 Vuex
import store from './store'
import router from './router'

import '@/icons' // icon
import '@/permission' // permission control
import request from '@/utils/request'
// import { imgerror, color } from '@/directives'
import * as directives from '@/directive'
import * as filters from '@/filters'
import Print from 'vue-print-nb'

Vue.use(Print)

Vue.prototype.$request = request

import Components from '@/components'
Vue.use(Components)

// import PageTools from '@/components/PageTools'
// Vue.component('PageTools', PageTools)

/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */

// set ElementUI lang to EN
Vue.use(ElementUI)
// Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui，按如下方式声明
// Vue.use(ElementUI)

Vue.config.productionTip = false

// 注册一个全局自定义指令 `v-xxx` 'v-yyy' 'v-imgerror'
// Vue.directive('imgerror', imgerror)
// Vue.directive('color', color)
// for (const key in directives) {
//   Vue.directive(key, directives[key])
// }

// 批量注册全局的自定义指令
Object.keys(directives).forEach(key => {
  Vue.directive(key, directives[key])
})

Object.keys(filters).forEach(key => {
  // console.log(key)
  Vue.filter(key, filters[key])
})

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
